import request from './request'

const http ={
    get(url: string){
        return request({
            method: 'get',
            url: url
        })
    },
    post(url: string, data: any){
        clearNullField(data.params)
        return request({
            method: 'post',
            url: url,
            data: data
        })
    }
}

// 删除为null或空字符的入参
function clearNullField(params:any) {
    for(let item in params) { 
        if(params[item] === null 
            || params[item] === '') {
            delete params[item]
        }
    }
}
export default http